package org.dtp.alarm;

import org.dtp.config.ThreadPoolProperties;

import java.util.List;

/**
 * @ClassName AlarmMessage
 * @Description 告警参数
 * @Author wangyiqi
 * @Date 2021-08-11-20:39
 **/
public class AlarmMessage {

    /**
     * 告警线程名称
     */
    private String alarmThreadName;

    /**
     * 告警消息
     */
    private List<String> alarmReasons;

    /**
     * 队列任务数量
     */
    private Integer queueTaskCount;

    /**
     * 拒绝任务数量
     */
    private Integer rejectTaskCount;

    /**
     * 线程池参数
     */
    private ThreadPoolProperties threadPoolProperties;

    /**
     * 告警时间间隔，单位：ms
     */
    private int alarmTimeInterval;

    public String getAlarmThreadName() {
        return alarmThreadName;
    }

    public void setAlarmThreadName(String alarmThreadName) {
        this.alarmThreadName = alarmThreadName;
    }

    public List<String> getAlarmReasons() {
        return alarmReasons;
    }

    public void setAlarmReasons(List<String> alarmReasons) {
        this.alarmReasons = alarmReasons;
    }

    public Integer getQueueTaskCount() {
        return queueTaskCount;
    }

    public void setQueueTaskCount(Integer queueTaskCount) {
        this.queueTaskCount = queueTaskCount;
    }

    public Integer getRejectTaskCount() {
        return rejectTaskCount;
    }

    public void setRejectTaskCount(Integer rejectTaskCount) {
        this.rejectTaskCount = rejectTaskCount;
    }

    public ThreadPoolProperties getThreadPoolProperties() {
        return threadPoolProperties;
    }

    public void setThreadPoolProperties(ThreadPoolProperties threadPoolProperties) {
        this.threadPoolProperties = threadPoolProperties;
    }

    public int getAlarmTimeInterval() {
        return alarmTimeInterval;
    }

    public void setAlarmTimeInterval(int alarmTimeInterval) {
        this.alarmTimeInterval = alarmTimeInterval;
    }

    private AlarmMessage(Builder builder) {
        this.alarmThreadName = builder.alarmThreadName;
        this.alarmReasons = builder.alarmReasons;
        this.queueTaskCount = builder.queueTaskCount;
        this.rejectTaskCount = builder.rejectTaskCount;
        this.threadPoolProperties = builder.threadPoolProperties;
        this.alarmTimeInterval = builder.alarmTimeInterval;
    }

    @Override
    public String toString() {
        return "AlarmMessage{" +
                "alarmThreadName='" + alarmThreadName + '\'' +
                ", alarmReasons='" + alarmReasons + '\'' +
                ", queueTaskCount=" + queueTaskCount +
                ", rejectTaskCount=" + rejectTaskCount +
                ", threadPoolProperties=" + threadPoolProperties +
                ", alarmTimeInterval=" + alarmTimeInterval +
                '}';
    }

    public static class Builder {
        /**
         * 告警线程名称
         */
        private String alarmThreadName;

        /**
         * 告警消息
         */
        private List<String> alarmReasons;

        /**
         * 队列任务数量
         */
        private Integer queueTaskCount;

        /**
         * 拒绝任务数量
         */
        private Integer rejectTaskCount;

        /**
         * 线程池参数
         */
        private ThreadPoolProperties threadPoolProperties;

        /**
         * 告警时间间隔，单位：ms
         */
        private int alarmTimeInterval = 1000;

        Builder() {
        }

        public Builder alarmThreadName(String alarmThreadName) {
            this.alarmThreadName = alarmThreadName;
            return this;
        }

        public Builder alarmReasons(List<String> alarmReasons) {
            this.alarmReasons = alarmReasons;
            return this;
        }

        public Builder queueTaskCount(Integer queueTaskCount) {
            this.queueTaskCount = queueTaskCount;
            return this;
        }

        public Builder rejectTaskCount(Integer rejectTaskCount) {
            this.rejectTaskCount = rejectTaskCount;
            return this;
        }

        public Builder threadPoolProperties(ThreadPoolProperties threadPoolProperties) {
            this.threadPoolProperties = threadPoolProperties;
            return this;
        }

        public Builder alarmTimeInterval(int alarmTimeInterval) {
            this.alarmTimeInterval = alarmTimeInterval;
            return this;
        }

        public AlarmMessage build() {
            return new AlarmMessage(this);
        }
    }
}
